$(document).ready(function() {
    const TIN=Number($("#s_income").text())-Number($("#s_outcome").text());
    const chart = {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false
    };
    let title;
    let dayinfo;
    if($("#s_day").text()!==""){
        dayinfo = $("#s_day").text().split("-");
        if(!isNaN(Number(dayinfo[2]))&&!isNaN(Number(dayinfo[1]))&&!isNaN(Number(dayinfo[0]))){
            title= {
                text: '日收入统计('+Number(dayinfo[0])+'年'+Number(dayinfo[1])+'月'+Number(dayinfo[2])+'日'+')'
            }
        }
    }else {
        dayinfo = $("#s_mouth").text().split("-");
        if(!isNaN(Number(dayinfo[1]))&&!isNaN(Number(dayinfo[0]))){
            title= {
                text: '月收入统计('+Number(dayinfo[0])+'年'+Number(dayinfo[1])+'月'+')'
            }
        }
    }
    const tooltip = {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    };
    const plotOptions = {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: false
            },
            showInLegend: true
        }
    };
    const series = [{
        type: 'pie',
        name: 'Browser share',
        data: [
            ['月卡收入:'+Number($("#s_Y_income").text())+' 元', Number($("#s_Y_income").text())],
            ['月卡支出（退费）:'+Number($("#s_Y_outcome").text())+' 元',Number($("#s_Y_outcome").text())],
            ['次卡收入:'+Number($("#s_C_income").text())+' 元',Number($("#s_C_income").text())],
            ['次卡支出(退费):'+Number($("#s_C_outcome").text())+' 元',Number($("#s_C_outcome").text())],
            ['总支出(退费):'+Number($("#s_outcome").text())+' 元',Number($("#s_outcome").text())],
            {
                name: '实际收入:'+TIN+' 元',
                y: Number($("#s_income").text())-Number($("#s_outcome").text()),
                sliced: true,
                selected: true
            },
        ]
    }];

    const json = {};
    json.chart = chart;
    json.title = title;
    json.tooltip = tooltip;
    json.series = series;
    json.plotOptions = plotOptions;
    $('#container').highcharts(json);
});